Skip to content

Conversation

@amomchilov
Copy link
Contributor

This PR enables -Wimplicit-fallthrough to catch any potentially unintended fall-through between case bodies.

The exiting /* fallthrough */ comments are now formalized with a new PRISM_FALLTHROUGH macro which:

  • Uses C23's standardized [[fallthrough]] attribute, if available,
  • Uses __attribute__((fallthrough)) on GCC and Clang
  • Uses to __fallthrough on MSVC

@amomchilov amomchilov changed the title Enable implicit fallt-through errors Enable implicit fall-through errors Dec 18, 2024
@amomchilov amomchilov force-pushed the detect-implicit-fallthrough branch from b81662a to 2389d0c Compare December 18, 2024 18:43
@amomchilov amomchilov force-pushed the detect-implicit-fallthrough branch from 2389d0c to 03797b8 Compare December 18, 2024 18:46
if (pm_symbol_node_label_p(node)) {
return node;
}
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one had an implicit fall-through that wasn't annotated.

Since the default case it falls into only does a break, I just added its own break instead of PRISM_FALLTHROUGH.

@tenderlove tenderlove merged commit 4507b6d into ruby:main Dec 19, 2024
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants